CXXFLAGS=-I../include -Wall -O2 -g3
LDFLAGS=-Wall -L../ -lnetpp -L../
LD_LIBRARY_PATH=../

srcs=$(wildcard *.cpp)
targets=$(shell ls *.cpp | sed -re 's/.cpp//g')
tests=$(shell ls *.cpp | sed -re 's/.cpp/test/g')

DEBUGFLAGS=-DDEBUG
tfile=../data/example_msg.hl7
tfile2=../data/adt_a04_13885_20090811203018

.EXPORT_ALL_VARIABLES: environ
.PHONY: clean environ

all: clean $(targets) $(tests)

httpclient: httpclient.cpp
	@echo [CXX] $?
	@$(CXX) $(CXXFLAGS) $(LDFLAGS) $? -o $@

sock: sock.cpp
	@echo [CXX] $?
	@$(CXX) $(CXXFLAGS) $(LDFLAGS) $? -o $@

tcpclient: tcpclient.cpp
	@echo [CXX] $?
	@$(CXX) $(CXXFLAGS) $(LDFLAGS) $? -o $@

httpclienttest: httpclient
	@echo [httptest] ./$@
	@./$? www.google.com /pda 80

socktest: sock
	@echo [socktest] ./$@
	@./$?

tcpclienttest: tcpclient
	@echo [tcpclienttest] ./$@
	@./$?

sockmem: sock
	@echo [memcheck] $@
	@valgrind --track-origins=yes --leak-check=full -v ./$? 

httpclientmem: httpclient
	@echo [memcheck] $@
	@valgrind --track-origins=yes --leak-check=full -v ./$? www.google.com /pda 80

clean:
	@echo [clean]
	@-rm -f $(targets) core

environ:
	@echo fixing environ - make sure libnetpp has been built before running these tests!

tags:
	ln -s ../tags
